/*

Author   : chaos

FileName : stl_alg_data.cpp

Date     : 17/08/17 11:33:50

*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using namespace std;

template <class  T>
void print(vector<T> & pri_con)
{
    if(pri_con.empty())
        cout << "Container is empty !" << endl;
    else
    {
        typename vector<T>::iterator i;
        for(i = pri_con.begin(); i != pri_con.end(); i++)
        { cout << *i << " "; }
        cout << endl;
    }
}

int main(int argc ,char *argv[])
{
    vector<char> v1(10);

    cout << "Fill v1 with 'A' ..." << endl;
    fill(v1.begin(),v1.end(),'A');
    print(v1);

    cout << "Copy v2 to v1 ..." << endl;
    char a[] = {'B','B','B','B'};
    vector<char> v2(a,a+4);

    copy(v2.begin() ,v2.end() , v1.begin() + 2);
    print(v1);

    cout << "Remove 'A' form v1 ..." << endl;
    vector<char>::iterator new_end;
    new_end = remove(v1.begin(), v1.end(),'A');
    v1.erase(new_end,v1.end());
    print(v1);

    cout << "Replace 'B' with 'C' ..." << endl;
    replace(v1.begin() ,v1.begin() +2,'B','C');
    print(v1);

    return 0;
}
